package com.kesh.ltank.screens;

import android.content.SharedPreferences;

import com.android.framework.Audio;
import com.android.framework.Game;
import com.android.framework.Graphics;
import com.android.framework.Screen;
import com.kesh.ltank.game.GlobalVars.GameImages;
import com.kesh.ltank.game.GlobalVars.GameMusic;
import com.kesh.ltank.game.GlobalVars.GameSounds;
import com.kesh.ltank.game.GlobalVars.PlayImages;
import com.kesh.ltank.game.GlobalVars.ScreenImages;
import com.kesh.ltank.game.GlobalVars;
import com.kesh.ltank.game.Utils;

public class LoadingScreen extends Screen {

	public LoadingScreen(Game game) {
		super(game);
	}

	@Override
	public void update(float deltaTime) {
		Graphics g = game.getGraphics();
		Audio a = game.getAudio();

		for(GameMusic gameMusic: GameMusic.values()){
			if(!gameMusic.name().equalsIgnoreCase("Theme1"))
				gameMusic.loadMusic(a);
		}
		
		for(GameSounds gameMusic: GameSounds.values()){
			gameMusic.loadSound(a);
		}

		for (ScreenImages screenImage : ScreenImages.values()) {
			screenImage.loadImage(g);
		}
		
		for (GameImages gameImage : GameImages.values()) {
			gameImage.loadImage(g);
		}
		
		for (PlayImages playImage : PlayImages.values()) {
			playImage.loadImage(g);
		}
		
		Utils.loadLvlData(game.getFileIO());

		SharedPreferences settings = game.getFileIO().getSharedPref();
		GlobalVars.currentLevel = settings.getInt("PlayedLevels", GlobalVars.startLevel) + 1;

		for (int i = 0; i < 200; i++) {
			for (int j = 0; j < 10000; j++) {
				// TODO delay
			}
		}

		game.setScreen(new MainMenuScreen(game));
	}

	@Override
	public void paint(float deltaTime) {
		Graphics g = game.getGraphics();
		g.drawImage(ScreenImages.Splash.image, 0, 0);
	}

	@Override
	public void pause() {

	}

	@Override
	public void resume() {

	}

	@Override
	public void dispose() {

	}

	@Override
	public void backButton() {

	}
}